<?php
namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;    //引入hash

class GiftTypeRepository
{

    /**
     * 获取礼物分类详情
     * @param $id
     * @return bool
     * @throws BasicException
     */
    public function GiftTypeDetail($id)
    {
        $GiftTypeDetail = app('model_gift_type')->where('id',$id)->orderBy('id','desc')->first();
        return $GiftTypeDetail;
    }


    /**
     * 获取礼物分类列表
     * @param $where
     * @return bool
     * @throws BasicException
     */
    public function giftTypeList($where)
    {
        $giftTypeList = app('model_gift_type')->orderBy('id','desc')->where($where)->get()->toArray();
        if($giftTypeList) return $giftTypeList;
        //throw new BasicException(50012);
    }

    /**
     * 添加礼物分类
     * @param $param
     * @return bool
     * @throws BasicException
     */
    public function addGiftType($param){
        $addGiftType = app('model_gift_type')->create($param);
        if($addGiftType) return $addGiftType;
        throw new BasicException(93025);
    }

    /**
     * 编辑礼物分类
     * @param $param
     * @return bool
     * @throws BasicException
     */
    public function  saveGiftType($param){
        $saveGiftType = app('model_gift_type')->where('id',$param['id'])->update($param);
        if($saveGiftType!==false) return true;
        throw new BasicException(93026);
    }

    /**
     * 删除礼物分类
     * @param $param
     * @return bool
     * @throws BasicException
     */

    public function  delGiftType($param){
        $delGiftType = app('model_gift_type')->whereIn('id',$param)->delete();
        if($delGiftType) return $delGiftType;
        throw new BasicException(93027);
    }

}


?>